#ifndef GAMEENGINE_GRAPHICS_MESHES_TRGL_MESH_GROUP_H
#define GAMEENGINE_GRAPHICS_MESHES_TRGL_MESH_GROUP_H

#include <GameEngine/Graphics/graphics_settings.h>

#include <GameEngine/Graphics/Meshes/trgl_mesh_subgroup.h>
#include <GameEngine/Graphics/Meshes/surface_mesh.h>
#include <GameEngine/Core/string.h>

#include <vector>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

class TrglMesh;

//=================================================================================

//! Group of triangles in a triangulated surface mesh
/*!
 *  A group of triangles corresponds to a well-identified part of the whole triangle
 *  mesh. For instance, a tree is composed of a trunk and of a set of leaves, hence
 *  would probably be made of two groups of triangles.
 *
 *  A group of triangles handles a list of triangle subgroups. The main difference
 *  between groups and subgroups of triangles lies in the use of materials: a group
 *  of triangles can use several materials, whereas a subgroups has only one single
 *  associated material.
 */
class _Graphics_decl TrglMeshGroup {

public:
	TrglMeshGroup();
	TrglMeshGroup(const TrglMeshGroup& rhs);
	virtual ~TrglMeshGroup();
	TrglMeshGroup& operator=(const TrglMeshGroup& rhs);

	const GEString& name() const;
	GEString& name();

	const std::vector<TrglMeshSubGroup>& subgroups() const;
	std::vector<TrglMeshSubGroup>& subgroups();

	SurfaceMesh::FaceCount face_count() const;

	void clear();

	bool render_group(const Line3d<float>& ray, const TrglMesh& mesh, bool transparency);

protected:
	//! Name of the triangle group
	GEString name_;

	//! List of triangle subgroups
	GAMEENGINE_DLL_CLASS_STD(vector,TrglMeshSubGroup) subgroups_;
};

//=================================================================================


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
